package com.huaxin.hxmoduleworkorder.models;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.huaxin.hxmoduleworkorder.common.ListMapToJsonTypeHandler;
import com.huaxin.hxmoduleworkorder.common.StringListToJsonTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@Data
@TableName(value = "maintenance_order_electrician_result", autoResultMap = true)
@EqualsAndHashCode(callSuper = true)
public class MaintenanceOrderElectricianTaskResult extends BaseModel {
    @TableField(value = "maintenance_order_id")
    @Schema(description = "工单ID", example = "mnt_order_001")
    private String maintenanceOrderId;

    @TableField(value = "maintenance_order_electrician_task_id")
    @Schema(description = "工单电工任务ID", example = "mnt_order_electrician_task_001")
    private String maintenanceOrderElectricianTaskId;

    @TableField(value = "electrician_id")
    @Schema(description = "处理电工ID", example = "e1001")
    private String electricianId;

    @TableField(value = "problem_description")
    @Schema(description = "问题描述", example = "零线接触不良导致跳闸")
    private String problemDescription;

    @TableField(value = "solution")
    @Schema(description = "解决方案", example = "重新压接零线端子并加固")
    private String solution;

    @TableField(value = "work_hours")
    @Schema(description = "工作时长（小时）", example = "1.5")
    private BigDecimal workHours;

    @TableField(value = "parts_used", typeHandler = ListMapToJsonTypeHandler.class)
    @Schema(description = "更换零件（JSON数组：名称、数量、单价等）", example = "[{\"name\":\"空开\",\"qty\":1,\"price\":80}]")
    private List<Map<String, Object>> partsUsed;

    @TableField(value = "photo_urls", typeHandler = StringListToJsonTypeHandler.class)
    @Schema(description = "现场处理照片", example = "[\"https://oss/repair1.jpg\"]")
    private List<String> photoUrls;

    @TableField(value = "sign_image_url")
    @Schema(description = "电子签名图片URL", example = "https://oss/sign_001.png")
    private String signImageUrl;
}